<script setup lang="ts">
import * as api from '@/api/auth'
import { useRequest } from 'alova/client'

const { data, send, loading } = useRequest(api.login, {
  immediate: false,
})

const userStore = useUserStore()
async function login() {
  const res = await send({
    username: 'admin',
    password: '123456',
  })
  userStore.setToken(res.data.token)
}
</script>

<template>
  <view>
    index
    <view @click="login">
      登录
    </view>
    <view>{{ userStore.isLogin ? '已登录' : '未登录' }}</view>
    {{ loading ? '登录中' : '' }}
    {{ data }}
  </view>
</template>

<style></style>

<route type="home" lang="json">
{}
</route>
